<?php
namespace app\home\controller;
use think\Controller;
use think\Db;
use third\Data;


class Base extends Controller{
    /*
   * 析构函数
   */
    public function __construct(){
        parent::__construct();
    }

    /*
     * 初始化操作
     */
    public function _initialize(){
        $this->request->isAjax() ? define('IS_AJAX',true) : define('IS_AJAX',false);  //
        ($this->request->method() == 'GET') ? define('IS_GET',true) : define('IS_GET',false);  //
        ($this->request->method() == 'POST') ? define('IS_POST',true) : define('IS_POST',false);  //

        define('MODULE_NAME',$this->request->module());  // 当前模块名称是
        define('CONTROLLER_NAME',$this->request->controller()); // 当前控制器名称
        define('ACTION_NAME',$this->request->action()); // 当前操作名称是
        define('PREFIX',C('database.prefix')); // 数据库表前缀

                        //网站基本信息
                $web = Db::name('web')->find();

                           //导航列表
        $nav = Db::name('category')->where(array('parent_id' => 0, 'is_show' => 1))
                                   ->order('list_order asc, cat_id desc')
                                   ->select();

                            //精品推荐
        $essenceArt = Db::name('article')->field('id, title, add_time')
                                        ->where(array('po_id' => 2, 'is_show' => 1))
                                        ->order('id desc')
                                        ->limit('6')
                                        ->select();

                             //热门标签
                $tag = Db::name('tag')->select();

                           //免费资源
                 $resources = Db::name('resources')->where('is_show', 1)->select();

                                    //留言列表
                 $msg = Db::name('message')->order('add_time desc')->where('is_show', 1)->select();

                             //友情链接
                $link = Db::name('Link')->where('is_show', 1)->order('id desc')->select();

         $this->assign('web' ,$web);
         $this->assign('nav' ,$nav);
         $this->assign('msg' ,$msg);
         $this->assign('essenceArt', $essenceArt);
         $this->assign('tag' ,$tag);
         $this->assign('resources' ,$resources);
         $this->assign('link' ,$link);



    }
}